package team

import (
	"sanguo/cluster"
	"sanguo/node/node_game"
	ss_msg "sanguo/protocol/ss/message"
	"time"

	"github.com/golang/protobuf/proto"
)

type Team struct {
	TeamID         uint64
	TeamHeader     bool
	HeartBeatStamp int64
}

func (this *Team) Heartbeat(roleID uint64, now time.Time) {
	if this.TeamHeader && now.Unix() > this.HeartBeatStamp+30 {
		req := &ss_msg.HeartbeatTeam{
			TeamID: proto.Uint64(this.TeamID),
			RoleID: proto.Uint64(roleID),
		}
		cluster.PostMessage(node_game.GetTeamServer().ToPeerID(), req)

		this.HeartBeatStamp = now.Unix()
	}
}
